﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="BrowseCategories.aspx.cs" Inherits="JustTest.Admin.BrowseCategories" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <h1>Categories:</h1>
    <label for="DropDownListCategoriesPerPage">Page size:</label>
    <asp:DropDownList ID="DropDownListCategoriesPerPage" runat="server"
        OnSelectedIndexChanged="DropDownListCategoriesPerPage_SelectedIndexChanged"
        AutoPostBack="true">
        <asp:ListItem Text="5" Value="5" Selected="True"/>
        <asp:ListItem Text="10" Value="10"/>
        <asp:ListItem Text="20" Value="20"/>
        <asp:ListItem Text="50" Value="50"/>
    </asp:DropDownList>

    <asp:GridView ID="GridViewCategories" runat="server" ItemType="JustTest.Models.Category"
        AutoGenerateColumns="false" AutoGenerateEditButton="true"
        DataKeyNames="Id"
        SelectMethod="GridViewCategories_GetData"
        UpdateMethod="GridViewCategories_UpdateItem"
        AllowPaging="true" PageSize="5"
        AllowSorting="true"
        CssClass="table table-hover table-striped">
        <Columns>
            <asp:DynamicField DataField="Name" />
            <asp:TemplateField HeaderText="Tests count">
                <ItemTemplate>
                    <asp:Label Text="<%# Item.Tests.Count %>" runat="server" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <EmptyDataTemplate>
            <div>No categories added yet.</div>
        </EmptyDataTemplate>
    </asp:GridView>
    <asp:ValidationSummary ID="ValidationSummary" runat="server" ShowSummary="true"
        DisplayMode="BulletList" Style="color: Red" />
    <asp:Button ID="ButtonTogleAddCategory" Text="New Category" runat="server" 
        OnClick="ButtonTogleAddCategory_Click"
        CssClass="btn btn-info"/>

    <asp:Panel ID="PanelAddCategory" runat="server" Visible="false">
        <label for="">New category name:</label>
        <asp:TextBox ID="TextBoxCategoryName" Text="" runat="server" ValidationGroup="ValidationGropuAddNewCategory" />
        <asp:RequiredFieldValidator ErrorMessage="Category name is required." ControlToValidate="TextBoxCategoryName"
            runat="server" Display="Dynamic" EnableClientScript="false" ValidationGroup="ValidationGropuAddNewCategory"/>
        <asp:RegularExpressionValidator Display="Dynamic" ControlToValidate="TextBoxCategoryName"
            CssClass="error" EnableClientScript="false" ValidationGroup="ValidationGropuAddNewCategory"
            ID="RegularExpressionValidatorCategoryName" ValidationExpression="^[\s\S]{1,25}$"
            runat="server" ErrorMessage="Minimum 1 and Maximum 25 characters required." />
        <br />
        <asp:Button ID="ButtonAddCategory" Text="Add category" runat="server" 
            OnClick="ButtonAddCategory_Click" 
            ValidationGroup="ValidationGropuAddNewCategory"
            CssClass="btn btn-info" />
    </asp:Panel>
</asp:Content>
